//1.二分-寻找旋转排序数组中的最小值
class Solution {
public:
    int findMin(vector<int>& nums) {
        int n = nums.size();
        int l = 0, r = n - 1;
        while(l < r)
        {
            int mid = (l + r) >> 1;
            if(nums[mid] >= nums[0]) l = mid + 1;
            else r = mid;
        }
        if(nums[l] > nums[0]) return nums[0];
        return nums[l];
    }
};


//2.二分-点名
class Solution {
public:
    int takeAttendance(vector<int>& records) {
        int l = 0, r = records.size() - 1;
        while(l < r)
        {
            int mid = (l + r) >> 1;
            if(records[mid] == mid) l = mid + 1; //1
            else r = mid;
        } 
        return l == records[l] ? l + 1 : l;
    }
};